package com.jd.cmdb.tsc.util;

import org.springframework.scheduling.support.CronSequenceGenerator;

import java.util.Date;
import java.util.TimeZone;

/**
 * Created by tianzhengguo on 2016/1/11.
 */
public class CronTabUtil {

    public static final TimeZone TIME_ZONE = TimeZone.getDefault();

    public static boolean isCronTab(String cron){
        try{
            CronSequenceGenerator csg = new CronSequenceGenerator(cron,TIME_ZONE);
        }catch (Exception e){
            return false;
        }
        return true;
    }

    public static Date getNextDate(String cron,Date curDate){
        CronSequenceGenerator csg = new CronSequenceGenerator(cron,TIME_ZONE);
        return csg.next(curDate);
    }
}
